package cn.gok.homework;

public class Student implements Comparable{
    private int sid;
    private String name;
    private int age;


    public Student(int sid, String name, int age) {
        this.sid = sid;
        this.name = name;
        this.age = age;
    }

    public int getSid() {
        return sid;
    }

    public void setSid(int sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(Object o) {
        Student student = (Student) o;
        if (this.getSid() > student.getSid()){
            return 1;
        }else if (this.getSid() < student.getSid()){
            return -1;
        }else {
            if (this.getAge()>student.getAge()){
                return 1;
            }else {
                return -1;
            }
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "sid=" + sid +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
